﻿var dictitemlist = {
    gridDefine: {
        toolbar: { items: [toolbarBtn.addDictitem] },
        columns: [
            { display: lang.type_ID, name: 'DICTTYPE_ID', minWidth: 60 },
            { display: lang.type_name, name: 'DICTTYPE_NAME', minWidth: 80 },
            { display: lang.element_name, name: 'ITEMNAME', minWidth: 90 },
            { display: lang.enname, name: 'ITEMDESC', minWidth: 90 }, //英文名
            { display: lang.element_value, name: 'ITEMVALUE', minWidth: 80 },
            { display: lang.sequence, name: 'ITEMORDER', minWidth: 60 },
            { display: lang.operation, name: 'DICTTYPE_ID2', minWidth: 80, align: 'center', render: linkop }
        ],
        url: App_Config.TadongUrl + "/AjaxMappingHandler.aspx",
        urlType: "QueryDictItemList",
        params: function () { return $.getPara("dicttypeid"); }
    },
    init: function () {
        jsPageRender(this, true);
    },
    search: function () {
        jsPageSearch(this);
    }
    
};

function linkop(value, row, index) {
    return '<span><a href="javascript:void(0)" onclick="deletedictitem(\'' + row.DICTITEM_ID + '\');">'+lang.delete_+'</a></span>';
}

function deletedictitem(itemid) {
    $.extend($.messager.defaults, {
        ok: lang.ok,
        cancel: lang.cancel
    });
    $.confirm(lang.Sure_to_delete_element, lang.Delete_element, function (b) {
        if (b) {
            $.ajaxHandler({
                url: App_Config.TadongUrl + "/AjaxMappingHandler.aspx",
                urlType: "EditDictItem",
                model: function () { return $.toJSON({ 'action': 0, 'DICTITEM_ID': itemid }); },
                success: function (data) {
                    $.alert(lang.Successfully_deleted, null, function () { dictitemlist.search(); });
                }
            });
        }
    });
}